{ lib, config, ... }:
let
  self = config.flakeDeclared.networking.nix-community;
in
{
  options.flakeDeclared.networking.nix-community = {
    enable = lib.mkEnableOption "nix-community substituters connection improvement";
  };
  config = lib.mkIf self.enable {
    nix.settings = {
      trusted-substituters = [
        "https://nix-community.cachix.org"
        "https://nixpkgs-update-cache.nix-community.org"
      ];
      trusted-public-keys = [
        "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
        "nixpkgs-update-cache.nix-community.org-1:U8d6wiQecHUPJFSqHN9GSSmNkmdiFW7GW7WNAnHW0SM="
      ];
    };
  };
}
